package com.miao.controller.front;

import com.miao.service.UserService;
import com.miao.vo.RegisterVo;
import com.miao.vo.ResultVo;
import com.miao.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 丰
 * @date: 2023/3/2 17:59
 */
@RestController
@RequestMapping("/front/user")
@Api(tags = "用户接口")
public class UserController {

    @Autowired
    UserService userService;
    //TODO 可以改为自动登录

    @GetMapping("/getName/{userId}")
    @ApiOperation("通过id查询用户个人信息")
    public ResultVo<UserVo> getName(@PathVariable("userId") Integer userId){
        ResultVo resultVo = userService.getNameId(userId);
        return resultVo;
    }

    @GetMapping("/outName/{userId}")
    @ApiOperation("退出登录")
    public ResultVo<Integer> outName(@PathVariable("userId") Integer userId){
        ResultVo resultVo = userService.outNameId(userId);
        return resultVo;
    }

    @PostMapping("/register")
    @ApiOperation("注册")
    public ResultVo<RegisterVo> register(@RequestBody RegisterVo registerVo){
        ResultVo register = userService.register(registerVo);
        return register;
    }
}
